package com.wqnmdb.im.config;

import com.wqnmdb.im.domain.contants.ConstantEnum;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class Swagger2Configuration {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage(ConstantEnum.SWAGGER_SCAN_BASE_PACKAGE.getContent()))
                // 可以根据url路径设置哪些请求加入文档，忽略哪些请求
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .contact(new Contact("zy", "", "619675313@qq.com"))
                //设置文档的标题
                .title("IM服务")
                // 设置文档的描述
                .description("IM服务 API 接口文档")
                // 设置文档的版本信息-> 1.0.0 Version information
                .version("1.0.0")
                // 设置文档的License信息->1.3 License information
                .termsOfServiceUrl("http://www.wqnmdb.com")
                .build();
    }
}